/**
 * 装饰器版本
 */
import { Module, Mutation, VuexModule } from 'vuex-module-decorators';
import { GENDER } from '@/enum/user';

export interface UserInfo {
  id: number;
  opendId: string;
  nickName: string;
  gender: GENDER;

  avatarUrl: string;

  country: string;

  province: string;

  city: string;

  language: string;

  verificationCode: string;

  phone: string;
}

/**
 * 示例模块的store
 */
@Module({ name: 'user', namespaced: true })
export class UserModule extends VuexModule {
  public userInfo: UserInfo | Record<string, any> = {};

  public loginStatus = false;

  public get getUserInfo() {
    return this.userInfo;
  }

  public get getLoginStatus() {
    return this.loginStatus;
  }

  @Mutation
  public setUserInfo(userInfo: UserInfo) {
    this.userInfo = userInfo;
  }

  @Mutation
  resetUserInfo() {
    this.userInfo = {};
  }

  @Mutation
  resetLoginStatus() {
    this.loginStatus = false;
  }

  @Mutation
  public setLoginStatus(state: boolean) {
    this.loginStatus = state;
  }
}
